<template>
  <div class="login_style">
    <div class="login_box">
      <div class="avat_box">
        <img src="../assets/logo.png" alt />
      </div>
      <el-form :model="form" ref="loginFormRef" :rules="rules" label-width="0px" class="logins">
        <el-form-item prop="idnumber">
          <el-input v-model="form.idnumber" prefix-icon="el-icon-user-solid"></el-input>
        </el-form-item>
        <el-form-item prop="password">
          <el-input v-model="form.password" prefix-icon="el-icon-s-promotion" type="password"></el-input>
        </el-form-item>
        <el-form-item class="but">
          <el-button type="primary" @click="login">登陆</el-button>
          <el-button type="info" @click="resetLogin">重置</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      form: {
        idnumber: "120103198201017334",
        password: "ET2020666",
      },
      rules: {
        idnumber: [
          { required: true, message: "请输入活动名称", trigger: "blur" },
        ],
        password: [
          { required: true, message: "请输入活动名称", trigger: "blur" },
        ],
      },
    };
  },
  methods: {
    resetLogin() {
      console.log(this.$refs);
      this.$refs.loginFormRef.resetFields();
    },
    login() {
      this.$refs.loginFormRef.validate(async (res) => {
        console.log(res);
        if (!res) return;
        const { data: ress } = await this.$api.post("LoginEmploy", this.form);
        console.log(ress);
        if (ress.baseViewModel.responseCode !== 200)
          return this.$message.error("登陆失败");
        this.$message.success("登陆成功");
        window.sessionStorage.setItem("token", ress.data.idNumber);
        this.$router.push("/Home");
      });
    },
  },
};
</script>
<style lang="less" scoped>
.login_style {
  background: rgb(57, 177, 207);
  height: 100%;
}
.login_box {
  width: 550px;
  height: 300px;
  border-radius: 10px;
  background-color: white;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}
.avat_box {
  height: 130px;
  width: 130px;
  border: 1px solid #dddddd;
  border-radius: 50%;
  padding: 10px;
  box-shadow: 0 0 10px #dddddd;
  position: absolute;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: #ffffff;
  img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: #e8e8e8;
  }
}
.logins {
  position: absolute;
  bottom: 0;
  width: 100%;
  box-sizing: border-box;
  padding: 0 20px;
}
.but {
  display: flex;
  justify-content: flex-end;
}
</style>    
